﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SponsorshipManager.Client.Model;


namespace SponsorshipManager.Client.View
{
    /// <summary>
    /// Interaction logic for PageFunction1.xaml
    /// </summary>
    public partial class Login : PageFunction<bool>
    {
        public Login()
        {
            InitializeComponent();
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (User.LoginUser(Username.Text, Password.Password))
                OnReturn(new ReturnEventArgs<bool>(true));
            // close window
            else
                ErrorMessage.Visibility= Visibility.Visible;
                // show wrong password button

        }
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            OnReturn(new ReturnEventArgs<bool>(false));
        }

        private void LoginKeyDown(object sender, KeyEventArgs e)
        {
            ErrorMessage.Visibility = Visibility.Hidden;
        }
    }
}
